package com.itheima.Controller;



import com.itheima.domain.Item;
import com.itheima.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/item")
public class ItemController {
    @Autowired
    private ItemService itemService;
//    @RequestMapping("/findbyid")
//    public ModelAndView findById(@PathVariable("id")int id){
//        ModelAndView modelAndView = new ModelAndView();
//        modelAndView.addObject("item",itemService.findById(id));
//        modelAndView.setViewName("item");
//        return modelAndView;
//    }
@RequestMapping("/showDetail")
public String showDetail(Model model){
    Item item = itemService.findById(1);
    model.addAttribute("item", item);
    return "itemDetail";
}
}
